package pe.com.cotelasa.scp.entidad;

import java.io.Serializable;
import java.util.Collection;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;
import org.hibernate.annotations.LazyCollection;
import org.hibernate.annotations.LazyCollectionOption;

@Entity
@Table(name = "articulo",catalog = "bdcotelasa", schema = "cotelasa")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Articulo.findAll", query = "SELECT a FROM Articulo a"),
    @NamedQuery(name = "Articulo.findById", query = "SELECT a FROM Articulo a WHERE a.id = :id"),
    @NamedQuery(name = "Articulo.findByDescripcion", query = "SELECT a FROM Articulo a WHERE a.descripcion = :descripcion"),
    @NamedQuery(name = "Articulo.findByModelo", query = "SELECT a FROM Articulo a WHERE a.modelo = :modelo"),
    @NamedQuery(name = "Articulo.findByDetalle", query = "SELECT a FROM Articulo a WHERE a.detalle = :detalle"),
    @NamedQuery(name = "Articulo.findByDatosTecnicos", query = "SELECT a FROM Articulo a WHERE a.datosTecnicos = :datosTecnicos"),
    @NamedQuery(name = "Articulo.findByNombreComercial", query = "SELECT a FROM Articulo a WHERE a.nombreComercial = :nombreComercial"),
    @NamedQuery(name = "Articulo.findByEstadoRegistro", query = "SELECT a FROM Articulo a WHERE a.estadoRegistro = :estadoRegistro"),
    @NamedQuery(name = "Articulo.findByUsrCreacion", query = "SELECT a FROM Articulo a WHERE a.usrCreacion = :usrCreacion"),
    @NamedQuery(name = "Articulo.findByFecCreacion", query = "SELECT a FROM Articulo a WHERE a.fecCreacion = :fecCreacion"),
    @NamedQuery(name = "Articulo.findByUsrModificacion", query = "SELECT a FROM Articulo a WHERE a.usrModificacion = :usrModificacion"),
    @NamedQuery(name = "Articulo.findByFecModificacion", query = "SELECT a FROM Articulo a WHERE a.fecModificacion = :fecModificacion")})
public class Articulo implements Serializable {
    
    @Id
    @SequenceGenerator(name = "generadorArticulo", sequenceName = "cotelasa.articulo_id_seq")
    @GeneratedValue(generator = "generadorArticulo")
    @Basic(optional = false)
    @Column(name = "id")
    private Integer id;
    
    @Column(name = "descripcion")
    private String descripcion;
    
    @Column(name = "modelo")
    private String modelo;
    
    @Column(name = "detalle")
    private String detalle;
    
    @Column(name = "datos_tecnicos")
    private String datosTecnicos;
    
    @Column(name = "nombre_comercial")
    private String nombreComercial;
    
    @Basic(optional = false)
    @Column(name = "estado_registro")
    private char estadoRegistro;
    
    @Basic(optional = false)
    @Column(name = "usr_creacion")
    private String usrCreacion;
    
    @Basic(optional = false)
    @Column(name = "fec_creacion")
    @Temporal(TemporalType.TIMESTAMP)
    private Date fecCreacion;
    
    @Column(name = "usr_modificacion")
    private String usrModificacion;
    
    @Column(name = "fec_modificacion")
    @Temporal(TemporalType.TIMESTAMP)
    private Date fecModificacion;
    
    @JoinTable(name = "proveedor_articulo",catalog="bdcotelasa",schema="cotelasa", joinColumns = {
        @JoinColumn(name = "id_articulo", referencedColumnName = "id")}, inverseJoinColumns = {
        @JoinColumn(name = "id_proveedor", referencedColumnName = "id")})
    @ManyToMany(fetch=FetchType.LAZY)
    private Collection<Proveedor> proveedorCollection;
    
    @JoinColumn(name = "id_categoria_articulo", referencedColumnName = "id")
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private CategoriaArticulo idCategoriaArticulo;
    
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idArticulo",fetch=FetchType.LAZY)
    private Collection<ComposicionArticulo> composicionArticuloCollection;
    
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idArticuloComp",fetch=FetchType.LAZY)
    private Collection<ComposicionArticulo> articuloComposicionCollection;
    
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idArticulo",fetch=FetchType.LAZY)
    private Collection<DetalleOrdenCompraServicio> detalleOrdenCompraServicioCollection;
    
    @OneToMany(mappedBy = "idArticulo",fetch=FetchType.LAZY)
    private Collection<Cotizacion> cotizacionCollection;
    
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "articulo",fetch=FetchType.LAZY)
    private Collection<ProveedorArticulo> proveedorArticuloCollection;
    
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idArticulo",fetch=FetchType.LAZY)
    private Collection<DetallePedidoOp> detallePedidoOpCollection;
    
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "articulo")
    private Collection<Kardex> kardexCollection;
    
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "articulo")
    private Collection<ArticuloSede> articuloSedeCollection;
    
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idArticulo")
    private Collection<MaterialConsumido> materialCunsumidoCollection;
    
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idArticulo")
    private Collection<CosteoArticulo> costeoArticuloCollection;
    
    public Articulo() {
    }

    public Articulo(Integer id) {
        this.id = id;
    }

    public Articulo(Integer id, char estadoRegistro, String usrCreacion, Date fecCreacion) {
        this.id = id;
        this.estadoRegistro = estadoRegistro;
        this.usrCreacion = usrCreacion;
        this.fecCreacion = fecCreacion;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getDescripcion() {
        return descripcion;
    }

    public void setDescripcion(String descripcion) {
        this.descripcion = descripcion;
    }

    public String getModelo() {
        return modelo;
    }

    public void setModelo(String modelo) {
        this.modelo = modelo;
    }

    public String getDetalle() {
        return detalle;
    }

    public void setDetalle(String detalle) {
        this.detalle = detalle;
    }

    public String getNombreComercial() {
        return nombreComercial;
    }

    public void setNombreComercial(String nombreComercial) {
        this.nombreComercial = nombreComercial;
    }

    public char getEstadoRegistro() {
        return estadoRegistro;
    }

    public void setEstadoRegistro(char estadoRegistro) {
        this.estadoRegistro = estadoRegistro;
    }

    public String getUsrCreacion() {
        return usrCreacion;
    }

    public void setUsrCreacion(String usrCreacion) {
        this.usrCreacion = usrCreacion;
    }

    public Date getFecCreacion() {
        return fecCreacion;
    }

    public void setFecCreacion(Date fecCreacion) {
        this.fecCreacion = fecCreacion;
    }

    public String getUsrModificacion() {
        return usrModificacion;
    }

    public void setUsrModificacion(String usrModificacion) {
        this.usrModificacion = usrModificacion;
    }

    public Date getFecModificacion() {
        return fecModificacion;
    }

    public void setFecModificacion(Date fecModificacion) {
        this.fecModificacion = fecModificacion;
    }

    @XmlTransient
    public Collection<Proveedor> getProveedorCollection() {
        return proveedorCollection;
    }

    public void setProveedorCollection(Collection<Proveedor> proveedorCollection) {
        this.proveedorCollection = proveedorCollection;
    }

    public CategoriaArticulo getIdCategoriaArticulo() {
        return idCategoriaArticulo;
    }

    public void setIdCategoriaArticulo(CategoriaArticulo idCategoriaArticulo) {
        this.idCategoriaArticulo = idCategoriaArticulo;
    }

    @XmlTransient
    public Collection<ComposicionArticulo> getComposicionArticuloCollection() {
        return composicionArticuloCollection;
    }

    public void setComposicionArticuloCollection(Collection<ComposicionArticulo> composicionArticuloCollection) {
        this.composicionArticuloCollection = composicionArticuloCollection;
    }
    
    public Collection<DetalleOrdenCompraServicio> getDetalleOrdenCompraServicioCollection() {
        return detalleOrdenCompraServicioCollection;
    }

    public void setDetalleOrdenCompraServicioCollection(Collection<DetalleOrdenCompraServicio> detalleOrdenCompraServicioCollection) {
        this.detalleOrdenCompraServicioCollection = detalleOrdenCompraServicioCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Articulo)) {
            return false;
        }
        Articulo other = (Articulo) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "pe.com.cotelasa.scp.entidad.Articulo[ id=" + id + " ]";
    }

    @XmlTransient
    public Collection<ProveedorArticulo> getProveedorArticuloCollection() {
        return proveedorArticuloCollection;
    }

    public void setProveedorArticuloCollection(Collection<ProveedorArticulo> proveedorArticuloCollection) {
        this.proveedorArticuloCollection = proveedorArticuloCollection;
    }

    @XmlTransient
    public Collection<Cotizacion> getCotizacionCollection() {
        return cotizacionCollection;
    }

    public void setCotizacionCollection(Collection<Cotizacion> cotizacionCollection) {
        this.cotizacionCollection = cotizacionCollection;
    }

    @XmlTransient
    public Collection<DetallePedidoOp> getDetallePedidoOpCollection() {
        return detallePedidoOpCollection;
    }

    public void setDetallePedidoOpCollection(Collection<DetallePedidoOp> detallePedidoOpCollection) {
        this.detallePedidoOpCollection = detallePedidoOpCollection;
    }

    public String getDatosTecnicos() {
        return datosTecnicos;
    }

    public void setDatosTecnicos(String datosTecnicos) {
        this.datosTecnicos = datosTecnicos;
    }
    
    @XmlTransient
    public Collection<ComposicionArticulo> getArticuloComposicionCollection() {
        return articuloComposicionCollection;
    }

    public void setArticuloComposicionCollection(Collection<ComposicionArticulo> articuloComposicionCollection) {
        this.articuloComposicionCollection = articuloComposicionCollection;
    }

    @XmlTransient
    public Collection<Kardex> getKardexCollection() {
        return kardexCollection;
    }

    public void setKardexCollection(Collection<Kardex> kardexCollection) {
        this.kardexCollection = kardexCollection;
    }

    public Collection<ArticuloSede> getArticuloSedeCollection() {
        return articuloSedeCollection;
    }

    public void setArticuloSedeCollection(Collection<ArticuloSede> articuloSedeCollection) {
        this.articuloSedeCollection = articuloSedeCollection;
    }

    @XmlTransient
    public Collection<MaterialConsumido> getMaterialCunsumidoCollection() {
        return materialCunsumidoCollection;
    }

    public void setMaterialCunsumidoCollection(Collection<MaterialConsumido> materialCunsumidoCollection) {
        this.materialCunsumidoCollection = materialCunsumidoCollection;
    }

    @XmlTransient
    public Collection<CosteoArticulo> getCosteoArticuloCollection() {
        return costeoArticuloCollection;
    }

    public void setCosteoArticuloCollection(Collection<CosteoArticulo> costeoArticuloCollection) {
        this.costeoArticuloCollection = costeoArticuloCollection;
    }

}
